<script setup>
import { onBeforeUnmount,ref } from 'vue';
import emitter from '@/untils/bus';

let message = ref()

emitter.on('sendDataTo1',data=>{
    message.value = data.msg
})

onBeforeUnmount(()=>{
    emitter.off('sendDataTo1')
})

</script>

<template>
    <div>
        <h2>组件1</h2>
        <div>收到消息：{{ message }}</div>
    </div>
</template>